<%@include file="../../taglibs.jsp" %>
<stripes:layout-render name="../../layout/baseview.jsp">
<stripes:layout-component name="head">
    <jsp:element name="meta">
            <jsp:attribute name="name">
                <c:out value="description"/>
            </jsp:attribute>
            <jsp:attribute name="content">
                <fmt:message key="page.createvacancy.description"/>
            </jsp:attribute>
    </jsp:element>
    <jsp:element name="meta">
            <jsp:attribute name="name">
                <c:out value="keywords"/>
            </jsp:attribute>
            <jsp:attribute name="content">
                <fmt:message key="page.main.keywords"/>
            </jsp:attribute>
    </jsp:element>
    <title>
        <fmt:message key="page.createvacancy.title"/>
    </title>

    <script type="text/javascript"
            src="${pageContext.request.contextPath}/ajax/prototype.js"></script>
    <script type="text/javascript" xml:space="preserve">
        function invoke(form, event, container) {
            var params = Form.serialize(form, {submit:event});
            new Ajax.Updater(container, 'Vacancy.action?updateCities=', {method:'post', parameters:params});
        }

    </script>
</stripes:layout-component>

<jsp:useBean id="dataUtils" class="ua.com.alus.resvac.crm.util.DataUtils" scope="session"/>

<stripes:layout-component name="content">
<br/>
<br/>
<stripes:link href="/vacancy/Vacancy.action?listVacancies=" class="flowlink">
    <fmt:message key="page.createvacancy.listvacancies"/>
</stripes:link>
<br/>
<br/>
<br/>
<stripes:label name="vacancy.createnewform"/>

<stripes:form id="vacancyForm" action="/vacancy/Vacancy.action">
<div class="errors">
<stripes:errors globalErrorsOnly="true"/>

<table class="form">
<!-- These fields are needed for updating vacancy -->
<stripes:hidden name="vacancy.uuid"/>
<stripes:hidden name="vacancy.accountUUID"/>


<!--position -->
<tr>
    <td>
        <stripes:label name="labelVacancyName"/>
    </td>
    <td>
        <stripes:text name="vacancy.position"/>
    </td>
    <td>
        <div class="fielderror">
            <stripes:errors field="vacancy.position"/>
        </div>
    </td>
</tr>

<!--professional area -->
<tr>
    <td>
        <stripes:label name="labelProfessionalArea"/>
    </td>
    <td>
        <stripes:select name="vacancy.fkProfAreaUuid">
            <stripes:option value="">
                <fmt:message key="page.createresume.choose"/>
            </stripes:option>
            <stripes:options-collection collection="${actionBean.baseService.professionAreas}"
                                        label="name"
                                        value="uuid"/>
        </stripes:select>
    </td>
    <td>
        <div class="fielderror">
            <stripes:errors field="vacancy.fkProfAreaUuid"/>
        </div>
    </td>
</tr>

<!-- Region -->
<tr>
    <td>
        <stripes:label name="labelRegion"/>
    </td>
    <td>
        <stripes:select id="region" name="vacancy.fkRegionId" onchange="invoke(this.form, this.name, 'city');">
            <stripes:option value="">
                <fmt:message key="page.createresume.choose"/>
            </stripes:option>
            <stripes:options-collection collection="${actionBean.baseService.regions}"
                                        label="name"
                                        value="id"/>
        </stripes:select>
    </td>
    <td>
        <div class="fielderror">
            <stripes:errors field="vacancy.fkRegionId"/>
        </div>
    </td>
</tr>

<!-- Region -->
<tr id="city">
    <td>
        <stripes:label name="labelPlace"/>
    </td>
    <td>
        <stripes:select name="vacancy.fkCityId">
            <stripes:option value="">
                <fmt:message key="page.createresume.choose"/>
            </stripes:option>
            <stripes:options-collection collection="${actionBean.cities}"
                                        label="name"
                                        value="id"/>
        </stripes:select>
    </td>
    <td>
        <div class="fielderror">
            <stripes:errors field="vacancy.fkCityId"/>
        </div>
    </td>
</tr>

<!--type of employment -->
<tr>
    <td>
        <stripes:label name="labelTypeOfEmployment"/>
    </td>
    <td>
        <stripes:select name="vacancy.typeOfEmployment">
            <stripes:option value="">
                <fmt:message key="page.createresume.choose"/>
            </stripes:option>
            <stripes:options-enumeration enum="ua.com.alus.resvac.crm.domen.prototype.TypeOfEmployment"/>
        </stripes:select>
    </td>
    <td>
        <div class="fielderror">
            <stripes:errors field="vacancy.typeOfEmployment"/>
        </div>
    </td>
</tr>

<!--salary -->
<tr>
    <td>
        <stripes:label name="labelSalary"/>
    </td>
    <td>
        <stripes:text name="vacancy.salary"/>
    </td>
    <td>
        <div class="fielderror">
            <stripes:errors field="vacancy.salary"/>
        </div>
    </td>
</tr>


<!--EXPIERENCE -->
<tr>
    <td>
        <stripes:label name="labelExperience"/>
    </td>
    <td>
        <stripes:select name="vacancy.experience">
            <stripes:option value="">
                <fmt:message key="page.createresume.choose"/>
            </stripes:option>
            <stripes:options-enumeration enum="ua.com.alus.resvac.crm.domen.prototype.Experience"/>
        </stripes:select>
    </td>
    <td>
        <div class="fielderror">
            <stripes:errors field="vacancy.experience"/>
        </div>
    </td>
</tr>

<!-- EDUCATION -->
<tr>
    <td>
        <stripes:label name="labelEducation"/>
    </td>
    <td>
        <stripes:select name="vacancy.education">
            <stripes:option value="">
                <fmt:message key="page.createresume.choose"/>
            </stripes:option>
            <stripes:options-enumeration enum="ua.com.alus.resvac.crm.domen.prototype.Education"/>
        </stripes:select>
    </td>
    <td>
        <div class="fielderror">
            <stripes:errors field="vacancy.education"/>
        </div>
    </td>
</tr>


<!--sex -->
<tr>
    <td>
        <stripes:label name="labelSex"/>
    </td>
    <td>
        <stripes:select name="vacancy.sex">
            <stripes:option value="">
                <fmt:message key="page.createresume.choose"/>
            </stripes:option>
            <stripes:options-enumeration enum="ua.com.alus.resvac.crm.domen.prototype.SexType"/>
        </stripes:select>
    </td>
    <td>
        <div class="fielderror">
            <stripes:errors field="vacancy.sex"/>
        </div>
    </td>
</tr>

<!-- age -->
<tr>
    <td>
        <stripes:label name="labelAge"/>
    </td>
    <td>
        <stripes:text name="vacancy.age"/>
    </td>
    <td>
        <div class="fielderror">
            <stripes:errors field="vacancy.age"/>
        </div>
    </td>
</tr>

    <!-- description -->
<tr>
    <td>
        <stripes:label name="labelDescription"/>
    </td>
    <td>
        <stripes:textarea name="vacancy.description" style="width:400px; height:100px"/>
    </td>
    <td>
        <div class="fielderror">
            <stripes:errors field="vacancy.description"/>
        </div>
    </td>
</tr>

    <!-- contacts -->
<tr>
    <td>
        <stripes:label name="labelContacts"/>
    </td>
    <td>

        <stripes:textarea name="vacancy.contacts" style="width:400px; height:100px"/>
    </td>
    <td>
        <div class="fielderror">
            <stripes:errors field="vacancy.contacts"/>
        </div>
    </td>
</tr>

   <!--status -->
<tr>
    <td>
        <stripes:label name="labelStatus"/>
    </td>
    <td>
        <stripes:select name="vacancy.status">
            <stripes:option value="">
                <fmt:message key="page.createresume.choose"/>
            </stripes:option>
            <stripes:options-enumeration enum="ua.com.alus.resvac.crm.domen.prototype.Status"/>
        </stripes:select>
    </td>
    <td>
        <div class="fielderror">
            <stripes:errors field="vacancy.status"/>
        </div>
    </td>
</tr>

<!-- file -->
<tr>
    <td>
        <stripes:label name="labelVacancyUpload"/>
    </td>
    <td>
        <stripes:file name="vacancyFile.fileBean"/>
    </td>
    <td>
        <div class="fielderror">
            <stripes:errors field="vaancyFile.fileBean"/>
        </div>
    </td>
</tr>
</table>
<stripes:label name="labelAttachedFiles"/>
<br/>
<% int i = 0; %>
<c:forEach items="${requestScope.actionBean.vacancyFilesUuid}" var="vacancyFileUuid">
    <%= ++i + "."%>
    <stripes:link href="/vacancy/Vacancy.action?deleteVacancyFile=&vacancyUuid=${requestScope.actionBean.vacancy.uuid}&vacancyFileUuid=${vacancyFileUuid}"
            class="flowlink">
        <fmt:message key="delete"/>
    </stripes:link>
    <br/>
</c:forEach>

</div>
<stripes:submit name="saveVacancy"/>
</stripes:form>

</stripes:layout-component>

</stripes:layout-render>